package bear.download;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class Msgread extends DefaultHandler {
	String sender,content,time,id,mesid,read;
	public static int n;
	String tagName;
	public static String sender1="",content1="",time1="",id1="",mesid1="",read1="";
	public void startDocument() throws SAXException {
		//System.out.println("````````begin````````");
		n=0;
	}

	public void endDocument() throws SAXException {
		//System.out.println("````````end````````");
		//System.out.println(n);
	}

	public void startElement(String namespaceURI, String localName,
			String qName, Attributes attr) throws SAXException {
		tagName = localName;
		if (localName.equals("pm")) {
				//获取标签的全部属性
				for (int i = 0; i < attr.getLength(); i++) {
					//id1=id1+attr.getValue(i)+"$";
			}			
		}
	}

	public void endElement(String namespaceURI, String localName, String qName)
			throws SAXException {
		//在worker标签解析完之后，会打印出所有得到的数据
		tagName = "";
		if (localName.equals("pm")) {
			printout();
			n++;
		}
	}

	public void characters(char[] ch, int start, int length)
			throws SAXException {
		if (tagName.equals("sender"))
			sender= new String(ch, start, length);
		else if (tagName.equals("time"))
			time = new String(ch, start, length);
		else if (tagName.equals("content"))
			content = new String(ch, start, length);
		else if (tagName.equals("id"))
			id = new String(ch, start, length);
		else if (tagName.equals("mesid"))
			mesid = new String(ch, start, length);
		else if (tagName.equals("read"))
			read = new String(ch, start, length);
	}

	public void printout() {
		sender1=sender1 + sender +"$";
		time1=time1 +time +"$";
		content1=content1+content+"$";
		id1=id1+id+"$";
		mesid1=mesid1+mesid+"$";
		read1=read1+read+"$";
	}
}
